/*Custom Dropdown function*/
$(function() {
$(".ci-dropdown").each(function(){
		$(this).click(function(e){
			e.stopPropagation(e); 
			$(this).toggleClass('active');	
			$(this).find('ul').slideToggle(100);
		});
		$(this).mouseleave(function(e){
			$(this).find('ul').slideUp(100);
			$(this).removeClass('active');
		});
		
		$(this).find('ul li a').click(function(e){
		
		var current=$(this).text();
	
		$(this).parents(".ci-dropdown").find('p').text(current);
		$(this).parent('ul').toggle();
		$(this).removeClass('active');
		});
	});
});

/*UI Jquery function*/
$(function() {
	
	$( "#accordion" ).accordion({
      heightStyle: "content"
    });
	$( "#accordion1" ).accordion({
      heightStyle: "content"
    });
	
	
	$('.floorContentadded ul li:last-child').addClass('last');
	
	$('.floorSection ul li:last-child').addClass('last');
	$('ul.subList li:last-child').addClass('last');
	
	$('div.archivedData div.archivedBox:first-child').addClass('first');
	$('div.archivedData div.archivedBox:last-child').addClass('last');
	
	$('.schoolEventstable tr').each(function(){
		$(this).hover(function(){
			$(this).children('td').addClass('hover');
		});
		$(this).mouseleave(function(e){
			$('.schoolEventstable tr td').removeClass('hover');
		});
	});
		
	$('.activeAcYear .schoolEventstable tr, .inActiveAcYear .schoolEventstable tr, .mark tr, .myClass .schoolEventstable tr').each(function(){
		$(this).hover(function(){
			$(this).children('td').removeClass('hover');
		});
	});
	
	$('.spin-left-arrow').click(function() {
       $(this).parents(".spinner").find('.up').show();
	   $(this).parents(".spinner").find('.down').hide();
    });
	$('.spin-right-arrow').click(function() {
		$(this).parents(".spinner").find('.down').show();
       	$(this).parents(".spinner").find('.up').hide();
    });
	
	$( "#tabs" ).tabs();
	$( "#tabs1" ).tabs();
	
	$('input.valIn').each(function(i, input) {
		$('.progressbar').eq(i).progressbar({
			value: Number($(input).val())
		});
	});
	
	$( document ).tooltip();
	$( ".selector" ).tooltip({ content: "Awesome title!" });
	
	// $(".datepicker").datepicker({
		// changeMonth: true,
		// changeYear: true
	// });
	// $(".datepickerIcon").datepicker({
		// changeMonth: true,
		// changeYear: true,
		// showOn: "button",
		// buttonImage: "images/calendar.png",
		// buttonImageOnly: true,
		// altField: ".datepickerIcon",
		// altFormat: "DD, d MM, yy"
	// });
	
	var settings = {
	autoReinitialise: true
	};
	var pane = $('.scroll-pane')
	pane.jScrollPane(settings);
	
	var pane = $('.scroll-pane1')
	pane.jScrollPane(settings);
	
	var pane = $('.scroll-pane2')
	pane.jScrollPane(settings);	
	
	var pane = $('.scroll-pane4')
	pane.jScrollPane(settings);
	
	var pane = $('.scroll-pane5')
	pane.jScrollPane(settings);
	
	var pane = $('.scroll-pane6')
	pane.jScrollPane(settings);
	
	var pane = $('.scroll-pane7')
	pane.jScrollPane(settings);
	
	var pane = $('.scroll-pane8')
	pane.jScrollPane(settings);
	
	var pane = $('.scroll-pane9')
	pane.jScrollPane(settings);
	
	var pane = $('.scroll-pane10')
	pane.jScrollPane(settings);
	
	var pane = $('.scroll-pane11')
	pane.jScrollPane(settings);
	
	var pane = $('.scroll-pane12')
	pane.jScrollPane(settings);
	
	var pane = $('.scroll-pane13')
	pane.jScrollPane(settings);
});

/* JqueryUI Dialog function*/

$(function() {
	$( "#dialog-student" ).dialog({
	autoOpen: false,
	width: 898,
	modal: true
	});
	$( ".add-student" ).click(function() {
		$( "#dialog-student" ).dialog( "open" );
	});
	$( "#saveInfo" ).click(function() {
		$( "#dialog-student" ).dialog( "close" );
	});
	$( "#cencelBox" ).click(function() {
		$( "#dialog-student" ).dialog( "close" );
	});
	
	$( "#dialog-define" ).dialog({
	autoOpen: false,
	width: 898,
	modal: true
	});
	$(".subjects").click(function() {
		$( "#dialog-define" ).dialog( "open" );
	});
	$("#dialog-define #saveInfo").click(function() {
		$( "#dialog-define" ).dialog( "close" );
	});
	$("#dialog-define #cencelBox").click(function() {
		$( "#dialog-define" ).dialog( "close" );
	});
	
	$( "#create-Section" ).dialog({
	autoOpen: false,
	width: 898,
	modal: true
	});
	$( ".createSection" ).click(function() {
		$( "#create-Section" ).dialog( "open" );
	});
	$( "#saveInfo" ).click(function() {
		$( "#create-Section" ).dialog( "close" );
	});
	$( "#cencelBox" ).click(function() {
		$( "#create-Section" ).dialog( "close" );
	});
	
	$( "#sub-CoScholastic" ).dialog({
	autoOpen: false,
	width: 898,
	modal: true
	});
	$( ".subCoScholastic" ).click(function() {
		$( "#sub-CoScholastic" ).dialog( "open" );
	});
	$( "#saveInfo" ).click(function() {
		$( "#sub-CoScholastic" ).dialog( "close" );
	});
	$( "#cencelBox" ).click(function() {
		$( "#sub-CoScholastic" ).dialog( "close" );
	});
	
	$( "#add-Term" ).dialog({
	autoOpen: false,
	width: 898,
	modal: true
	});
	$( ".addTerm" ).click(function() {
		$( "#add-Term" ).dialog( "open" );
	});
	$( "#add-Term #saveInfo" ).click(function() {
		$( "#add-Term" ).dialog( "close" );
	});
	$( "#add-Term #cencelBox" ).click(function() {
		$( "#add-Term" ).dialog( "close" );
	});
	
	$( "#dialog-summative" ).dialog({
	autoOpen: false,
	width: 898,
	modal: true
	});
	$( ".summative" ).click(function() {
		$( "#dialog-summative" ).dialog( "open" );
	});
	$( "#dialog-summative #save" ).click(function() {
		$( "#dialog-summative" ).dialog( "close" );
	});
	$( "#dialog-summative #cencel" ).click(function() {
		$( "#dialog-summative" ).dialog( "close" );
	});
	
	
	$( "#add-Event" ).dialog({
	autoOpen: false,
	width: 420,
	modal: true
	});
	$( ".addEvent" ).click(function() {
		$( "#add-Event" ).dialog( "open" );
	});
	$( "#saveInfo1" ).click(function() {
		$( "#add-Event" ).dialog( "close" );
	});
	$( "#cencelBox1" ).click(function() {
		$( "#add-Event" ).dialog( "close" );
	});
	
	$( "#dialog-Archive" ).dialog({
	autoOpen: false,
	width: 420,
	modal: true
	});
	$( ".archive" ).click(function() {
		$( "#dialog-Archive" ).dialog( "open" );
	});
	$( "#dialog-Archive #confirm" ).click(function() {
		$( "#dialog-Archive" ).dialog( "close" );
	});
	$( "#dialog-Archive #cancle" ).click(function() {
		$( "#dialog-Archive" ).dialog( "close" );
	});
	
	$( "#dialog-Analysis" ).dialog({
	autoOpen: false,
	width: 420,
	modal: true
	});
	$( ".analysis" ).click(function() {
		$( "#dialog-Analysis" ).dialog( "open" );
	});
	$( "#dialog-Analysis #save" ).click(function() {
		$( "#dialog-Analysis" ).dialog( "close" );
	});
	$( "#dialog-Analysis #cancel" ).click(function() {
		$( "#dialog-Analysis" ).dialog( "close" );
	});
	
	
	$( "#sub-CoScholastic" ).dialog({
	autoOpen: false,
	width: 898,
	modal: true
	});
	$( ".subCoScholastic" ).click(function() {
		$( "#sub-CoScholastic" ).dialog( "open" );
	});
	$( "#saveInfo" ).click(function() {
		$( "#sub-CoScholastic" ).dialog( "close" );
	});
	$( "#cencelBox" ).click(function() {
		$( "#sub-CoScholastic" ).dialog( "close" );
	});
	
	$( "#add-Schedule" ).dialog({
	autoOpen: false,
	width: 327,
	modal: true
	});
	$( ".addSchedule" ).click(function() {
		$( "#add-Schedule" ).dialog( "open" );
	});
	$( "#saveInfo2" ).click(function() {
		$( "#add-Schedule" ).dialog( "close" );
	});
	$( "#cencelBox2" ).click(function() {
		$( "#add-Schedule" ).dialog( "close" );
	});
	
	$( "#automated-timetable" ).dialog({
	autoOpen: false,
	width: 327,
	modal: true
	});
	$( ".automated" ).click(function() {
		$( "#automated-timetable" ).dialog( "open" );
	});
	$( "#automated-timetable #ok" ).click(function() {
		$( "#automated-timetable" ).dialog( "close" );
	});
	$( "#automated-timetable #cencel" ).click(function() {
		$( "#automated-timetable" ).dialog( "close" );
	});
	
	$( "#create-TimeTable" ).dialog({
	autoOpen: false,
	width: 327,
	modal: true
	});
	$( ".createTimeTable" ).click(function() {
		$( "#create-TimeTable" ).dialog( "open" );
	});
	$( "#create-TimeTable #ok" ).click(function() {
		$( "#create-TimeTable" ).dialog( "close" );
	});
	$( "#create-TimeTable #cencel" ).click(function() {
		$( "#create-TimeTable" ).dialog( "close" );
	});
	
	$( "#view-Teachers" ).dialog({
	autoOpen: false,
	width: 327,
	modal: true
	});
	$( ".viewTeachers" ).click(function() {
		$( "#view-Teachers" ).dialog( "open" );
	});
	$( "#view-Teachers #saveInfo" ).click(function() {
		$( "#view-Teachers" ).dialog( "close" );
	});
	$( "#view-Teachers #cencelBox" ).click(function() {
		$( "#view-Teachers" ).dialog( "close" );
	});
	
	$( "#dialog-publish" ).dialog({
	autoOpen: false,
	width: 327,
	modal: true
	});
	$( ".publish" ).click(function() {
		$( "#dialog-publish" ).dialog( "open" );
	});
	$( "#dialog-publish #confirm" ).click(function() {
		$( "#dialog-publish" ).dialog( "close" );
	});
	$( "#dialog-publish #cencel" ).click(function() {
		$( "#dialog-publish" ).dialog( "close" );
	});
	
	$( "#dialog-publish" ).dialog({
	autoOpen: false,
	width: 327,
	modal: true
	});
	$( ".publish" ).click(function() {
		$( "#dialog-publish" ).dialog( "open" );
	});
	$( "#dialog-publish #confirm" ).click(function() {
		$( "#dialog-publish" ).dialog( "close" );
	});
	$( "#dialog-publish #cencel" ).click(function() {
		$( "#dialog-publish" ).dialog( "close" );
	});
	
	$( "#dialog-Generate" ).dialog({
	autoOpen: false,
	width: 327,
	modal: true
	});
	$( ".generate" ).click(function() {
		$( "#dialog-Generate" ).dialog( "open" );
	});
	$( "#dialog-Generate #confirm" ).click(function() {
		$( "#dialog-Generate" ).dialog( "close" );
	});
	$( "#dialog-Generate #cencel" ).click(function() {
		$( "#dialog-Generate" ).dialog( "close" );
	});
	
	$( "#assign-Subject" ).dialog({
	autoOpen: false,
	width: 420,
	modal: true
	});
	$( ".assign" ).click(function() {
		$( "#assign-Subject" ).dialog( "open" );
	});
	$( "#assign-Subject #save" ).click(function() {
		$( "#assign-Subject" ).dialog( "close" );
	});
	$( "#assign-Subject #cencel" ).click(function() {
		$( "#assign-Subject" ).dialog( "close" );
	});
	
	$( "#create-Shift" ).dialog({
	autoOpen: false,
	width: 500,
	modal: true
	});
	$( ".createShift" ).click(function() {
		$( "#create-Shift" ).dialog( "open" );
	});
	$( "#create-Shift #save" ).click(function() {
		$( "#create-Shift" ).dialog( "close" );
	});
	$( "#create-Shift #cencel" ).click(function() {
		$( "#create-Shift" ).dialog( "close" );
	});
	
	$( "#dialog-clone" ).dialog({
	autoOpen: false,
	width: 420,
	modal: true
	});
	$( ".clone" ).click(function() {
		$( "#dialog-clone" ).dialog( "open" );
	});
	$( "#dialog-clone #clone" ).click(function() {
		$( "#dialog-clone" ).dialog( "close" );
	});
	$( "#dialog-clone #cencel" ).click(function() {
		$( "#dialog-clone" ).dialog( "close" );
	});
	
	/* function to show Assign Roll Numbers Dialog box */
	$( "#assign-roll" ).dialog({
	autoOpen: false,
	width: 400,
	modal: true
	});
	$( ".assignRoll" ).click(function() {
		$( "#assign-roll" ).dialog( "open" );
	});
	$( "#assign-roll #saveInfo" ).click(function() {
		$( "#assign-roll" ).dialog( "close" );
	});
	$( "#assign-roll #cencelBox" ).click(function() {
		$( "#assign-roll" ).dialog( "close" );
	});
	
	//Add Marks dialog box
	$( "#add-marks" ).dialog({
	autoOpen: false,
	width: 400,
	modal: true
	});
	$( ".addMarks" ).click(function() {
		$( "#add-marks" ).dialog( "open" );
	});
	$( "#add-marks #proceed" ).click(function() {
		$( "#add-marks" ).dialog( "close" );
	});
	$( "#add-marks #cencelBox" ).click(function() {
		$( "#add-marks" ).dialog( "close" );
	});
	
	//Course Completion dialog box
	$( "#course-completion" ).dialog({
	autoOpen: false,
	width: 898,
	modal: true
	});
	$( ".courseCompletion" ).click(function() {
		$( "#course-completion" ).dialog( "open" );
	});
	$( "#course-completion #okay" ).click(function() {
		$( "#course-completion" ).dialog( "close" );
	});
	$( "#course-completion #cencelBox" ).click(function() {
		$( "#course-completion" ).dialog( "close" );
	});
	
	//Class Performance dialog box
	$( "#class-performance" ).dialog({
	autoOpen: false,
	width: 898,
	modal: true
	});
	$( ".classPerformance" ).click(function() {
		$( "#class-performance" ).dialog( "open" );
	});
	$( "#class-performance #okay" ).click(function() {
		$( "#class-performance" ).dialog( "close" );
	});
	$( "#class-performance #cencelBox" ).click(function() {
		$( "#class-performance" ).dialog( "close" );
	});
	
	
	/*Active Inactive block function*/
	
		/*$('.activeTab a').click(function(){
			var $this = $(this);
			$this.parent().find('a').removeClass('active');
			$this.parent().find('a').addClass('inActive');
			$this.addClass('active');
			$this.removeClass('inActive');
			
		});*/
		var that;
		$('.activeTab a.activestate').click(function(){
			if($(this).hasClass('deselected')){
				$( "#dialog-confirm2" ).dialog( "open" );
				that = $(this);
			}
		});
		$('.activeTab a.inactivestate').click(function(){
			if($(this).hasClass('deselected')){
				$( "#dialog-confirm3" ).dialog( "open" );
				that = $(this);	
			}
		});

	
	
		$( "#dialog-confirm2" ).dialog({
			autoOpen: false,
			width: 420,
			modal: true
		});
		$( "#dialog-confirm2 #delete" ).click(function() {
			$( "#dialog-confirm2" ).dialog( "close" );
			if(that.hasClass('deselected')){
				that.addClass('selected');
				that.removeClass('deselected');
				that.siblings().removeClass('selected');
				that.siblings().addClass('deselected');
			}
		});
		$( "#dialog-confirm2 #cencel" ).click(function() {
			$( "#dialog-confirm2" ).dialog( "close" );
		});
		
		$("#dialog-confirm3").dialog({
			autoOpen: false,
			width: 420,
			modal: true
		});
		$( "#delete1" ).click(function() {
			$( "#dialog-confirm3" ).dialog( "close" );
			if(that.hasClass('deselected')){
				that.addClass('selected');
				that.removeClass('deselected');
				that.siblings().removeClass('selected');
				that.siblings().addClass('deselected');
			}
		});
		$( "#cencel1" ).click(function() {
			$( "#dialog-confirm3" ).dialog( "close" );
			
		});
		
	
	
	/*Delete block function*/

	$( "#dialog-confirm" ).dialog({
	autoOpen: false,
	width: 420,
	modal: true
	});
	$(".deleteIconTitle, .deleteRow").each(function() {
		$(this).click(function(event) {
			$( "#dialog-confirm" ).dialog( "open" );
		});
	});
	$("#dialog-confirm #delete").click(function(){
		$( "#dialog-confirm" ).dialog( "close" );
		$("h3.ui-accordion-header.ui-state-focus").next('div').remove();
		$("h3.ui-accordion-header.ui-state-focus").remove();
	});
	$("#dialog-confirm #cencel").click(function(){
		$( "#dialog-confirm" ).dialog( "close" );
	});
	
	$( "#dialog-confirm1" ).dialog({
	autoOpen: false,
	width: 420,
	modal: true
	});
	
	$(".deleteIcon, .crossIcon").each(function() {
		$(this).click(function() {
			$( "#dialog-confirm1" ).dialog( "open" );
			$(this).addClass('remove');
		});
	});
	$("#dialog-confirm1 #delete").click(function(){
		$( "#dialog-confirm1" ).dialog( "close" );
		var divparent = $('.remove').closest('div, tr, li');
		divparent.remove();
	});
	$("#dialog-confirm1 #cencel").click(function(){
		$( "#dialog-confirm1" ).dialog( "close" );
	});
	
	/*Select Class Room function*/
	
	$('a.seletc').hover(
		function(){
		var div = $(this).siblings('div.showBox, ul.selectClass');
		div.addClass('up');
		div.show();
		$(this).mouseout(function(){
			div.removeClass('up');
			div.hide();
		});
		div.mouseenter(function(){
			div.addClass('up');
			div.show();
		});
		div.mouseleave(function(){
			div.removeClass('up');
			div.hide();
		});
		$('.done').click(function(){
			div.hide();
		});
		
		var room = $('.showBox a.room');
		
		room.click(function(){
			$('.showBox a.room').removeClass('add');
			$(this).addClass('add');	
		});
		room.dblclick(function(){
			$(this).removeClass('add');
		});
		
	});
	
});

$(function() {
    var availableTags = [
      "Ms. David",
      "Ms. Dave",
      "Ms. Daisy",
      "Mr. Darshan Pandya"
    ];
    $( ".sugges" ).autocomplete({
      source: availableTags
    });
	
	var spinner = $( ".timeSpinner" ).spinner();
  });

